package com.example.rrr_map;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.example.rrr_map.Util.Global;




import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;


public class WarriorsActivity extends Activity {

	private ListView lvWarriors;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_warriors);
		
		lvWarriors = (ListView) findViewById(R.id.lvWarriors);
        // Instanciating an array list (you don't need to do this, you already have yours)
		
		
        
        ArrayList<User> Warriors = new ArrayList<User>();
        
        
        User u1 = new User("Mel Gibson", 24);
        Warriors.add(u1);
        User u2 = new User("Kevin Costner", 15);
        Warriors.add(u2);
        User u3 = new User("Oprah Winfrey", 2);
        Warriors.add(u3);
        // This is the array adapter, it takes the context of the activity as a first // parameter, the type of list view as a second parameter and your array as a third parameter
        
        //lvWarriors.setAdapter(arrayAdapter); 
        
        
        
        lvWarriors.setAdapter(new LVWarriorsAdapter(this, Warriors));

        lvWarriors.setOnItemClickListener(new OnItemClickListener() {
    		public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 
    			Object obj = lvWarriors.getItemAtPosition(position);
				User p = (User) obj;
    			Global.setOpponentID(p.getName()); //LAGA
    			Intent intent = new Intent(getApplicationContext(), OpponentActivity.class);
    			startActivity(intent);
    		}	
    	});
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.warriors, menu);
		return true;
	}

	
	
	

}

